package com.hejing.enum枚举类.认识enum枚举类;

/**
 * ClassName: SeasonTest
 * Package: com.hejing.enum枚举类
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-04-03 20:09
 * @Version: 1.0
 */
public class SeasonTest {
    public static void main(String[] args) {
        System.out.println(Season.SPRING);
    }
}

// jdk5.0之前定义枚举类的方式:
class Season{

    // 1、声明当前类的对象的实例变量:
    private final String seasonName;  // 季节的名称,不对外提供修改功能(final)
    private final String seasonDesc;  // 季节的描述，不对外提供修改功能(final)

    // 2、构造器私有:
    private Season(String seasonName, String seasonDesc){
        this.seasonName = seasonName;
        this.seasonDesc = seasonDesc;
    }

    // 3、提供实例变量的get方法

    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

    // 4、创建当前类的实例: 需要定位为全局常量 public static final
    public static final Season SPRING = new Season("春天", "春暖花开");
    public static final Season SUMMER = new Season("夏天", "夏日炎炎");
    public static final Season AUTUMN = new Season("秋天", "秋高气爽");
    public static final Season WINTER = new Season("冬天", "雪花飘飘");

    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }
}






















